<template>
  <div>
    <ContentTitle :info="ctInfo" />
      <el-table :data="accountList" style="width: 100%">
        <el-table-column type="index" label="序号" width="180"></el-table-column>
        <el-table-column prop="account" label="账号"></el-table-column>
        <el-table-column prop="username" label="用户名称"></el-table-column>
        <el-table-column prop="type" label="类型"> </el-table-column>
        <el-table-column prop="uTime" label="创建时间">
           <template slot-scope="scope">
            {{ scope.row.cTime | cTimeType }}
          </template>
        </el-table-column>
        <el-table-column prop="uTime" label="更新时间">
         <template slot-scope="scope">
            {{ scope.row.uTime | uTimeType }}
          </template>
        </el-table-column>
         <el-table-column prop="desc" label="描述"> </el-table-column>
        <el-table-column  label="操作" align="center">
          <el-button type="text" size="small">编辑</el-button>
          </el-table-column>
      </el-table>
  </div>
</template>

<script>
import ContentTitle from "@/components/ContentTitle.vue";
import {$accountList} from '@/api/index.js';
export default {
  name: "accountList.vue",
  components: { ContentTitle },
  data() {
    return {
      ctInfo: {
        type: "子账号",
        text: "子账号列表",
        msg: "展示当前组织下的所有子账号，可修改子账号信息或删除子账号。",
      },
      accountList:[]
    };
  },
   filters: {
    // //在线状态的过滤器
    // onlineType(value) {
    //   return value ? "在线" : "离线";
    // },
    uTimeType(value) {
      let date = new Date(value);
      let y = date.getFullYear(); // 获取完整的年份(4位,1970)
      let m = date.getMonth()+1; // 获取月份(0-11,0代表1月,用的时候记得加上1)
      let d = date.getDate(); // 获取日(1-31)
     let y1= y < 10 ? "0" + y : y;
     let m1= m < 10 ? "0" + m : m;
     let d1= d < 10 ? "0" + d : d;
      return `${y1} - ${m1} - ${d1}`;
    },
    cTimeType(value) {
      console.log(value);
     var value1 = value *1
      let date = new Date(value1);
      let y = date.getFullYear(); // 获取完整的年份(4位,1970)
      let m = date.getMonth(); // 获取月份(0-11,0代表1月,用的时候记得加上1)
      let d = date.getDate(); // 获取日(1-31)
     let y1= y < 10 ? "0" + y : y;
     let m1= m < 10 ? "0" + m : m;
     let d1= d < 10 ? "0" + d : d;
      return `${y1} - ${m1} - ${d1}`;
    },
  },
  created(){
      this.getAccount();
  },
  methods:{
      getAccount(){
          $accountList().then( res =>{
              console.log(res.data.data);
              this.accountList = res.data.data;
          })
      }
  }
};
</script>

<style>
</style>